package android.FiltrosJava;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;

public class GlowBlur extends AbstractImageBasic{
	public BufferedImage applyFilter(BufferedImage src) {
		ConvolveBlur3x3 ra = new ConvolveBlur3x3();				
		BufferedImage dst = ra.applyFilter(src);
		
		int dimX = src.getWidth();
        int dimY = src.getHeight();        
    	            	
    	WritableRaster raster_src = src.getRaster();
    	WritableRaster raster_dst = dst.getRaster();
    	int numBands = raster_src.getNumBands();
    	int[] imageDataSrc = new int[numBands];
    	int[] imageDataDst = new int[numBands];
    	
    	for ( int y = 0; y < dimY; y++ ) {
    		for ( int x = 0; x < dimX; x++ ) {
    			raster_src.getPixel(x,y,imageDataSrc);
    			raster_dst.getPixel(x,y,imageDataDst);
    			imageDataSrc[0] = delimitaCor(imageDataDst[0] + imageDataSrc[0]);
    			imageDataSrc[1] = delimitaCor(imageDataDst[1] + imageDataSrc[1]);
    			imageDataSrc[2] = delimitaCor(imageDataDst[2] + imageDataSrc[2]);
    			
    			raster_src.setPixel(x,y,imageDataSrc);    			
    		}
    	}
    	
		return src;
	}
}